import java.util.Random;

/**
 * 实现双色球抽奖游戏中奖号码的生成，中奖号码由 6 个红球号码和 1 个蓝球号码组成
 */
public class DoubleBallTest{

    public static void main(String[] args){
        //声明33个红球数的数组
        int[] nums = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33};
        //声明一个空数组用来进行红球过滤
        int[] nums1 = new int[32];
        //声明标识用来交换数据数据
        boolean flag = true;
        //第一个数组长度
        int numlen = nums.length;
        //第二个数组长度
        int newlen = nums1.length;
        
        Random random = new Random();
        //声明一个数组存储红球数据
        int[] redNums = new int[6];
        System.out.print("红球随机生成：");
        for(int i=0;i<6;i++){
            if(flag){
                int ranNum = random.nextInt(numlen);
                newlen = numlen - 1;
                nums1 = new int[newlen];
                for(int j=0;j<newlen;j++){
                    if(j<ranNum){
                        nums1[j] = nums[j];
                    }else{
                        nums1[j] = nums[j+1];
                    }
                }
                redNums[i] = nums[ranNum];
            }else{
                int ranNum = random.nextInt(newlen);
                numlen = newlen - 1;
                nums = new int[numlen];
                for(int j=0;j<numlen;j++){
                    if(j<ranNum){
                        nums[j] = nums1[j];
                    }else{
                        nums[j] = nums1[j+1];
                    }
                }
                redNums[i] = nums1[ranNum];
            }
            flag = !flag;
            System.out.print(redNums[i] + " ");
        }
        int blueNum = random.nextInt(16) + 1;
        System.out.print("蓝球随机生成：" + blueNum + " ");
    }
}